<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page language="java" import="java.util.*" %>
<jsp:directive.page import="com.xr.common.CommUtil"/>
<jsp:directive.page import="com.bstek.dorado.data.db.*"/>
<jsp:directive.page import="com.bstek.dorado.utils.variant.VariantSet"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>人力成本/收入</title>
<script language="javascript" src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/jquery1.8.2.min.js"></script>
 <script  src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/highcharts2.3.5.js"></script>
<script   src="<%=request.getContextPath()%>/dorado/smartweb2.loadUserLib.d?file=/lib/exporting2.3.5.js"></script>
<script type="text/javascript"> 
		 	<%
		 	DBStatement dbs=new DBStatement();
	    Map<String,String> hm=new HashMap();
		String costY="",incomeY="",xMonth="",sql="",series="";
		String sendMonthF="",sendMonthT="";  
		sendMonthF=request.getParameter("DATE_F");
		sendMonthT=request.getParameter("DATE_T");
		
//		  System.out.println("===="+sendMonthF==null+"========"+sendMonthF);
		 if (sendMonthF==null || sendMonthF.equals("null") || sendMonthF=="") return ;
		String comId=request.getParameter("COMPANY_ID");
		String hritemsId=request.getParameter("hritemsId");
		//String year=request.getParameter("year");
	    dbs.setSql("select months_between(to_date('"+sendMonthT+"01','yyyyMMdd'),to_date('"+sendMonthF+"01','yyyyMMdd')) from dual ");
		if(dbs.query().getInt(0)>24){
		   dbs.setSql("select to_char(add_months(to_date('"+sendMonthT+"01','yyyyMMdd'),-24),'yyyyMM') from dual ");
		   sendMonthF=dbs.query().getString(0);
		}
		
		VariantSet vs=null;
	 
 
		sql="select yue,"+
"(SELECT sum(d.value) from wa_data d,wa_psn p,wa_send s where p.psn_id=d.psn_id and s.send_id=p.send_id and s.send_month=yue and d.hritems_id ="+hritemsId+")costv,"+
"(select money from ot_business_stat where business_type=1 and if_sure=1 and yearmonth=yue)incomev "+
 " from (select to_char(add_months(to_date('"+sendMonthF+"01','yyyyMMdd'),level-1),'yyyyMM')yue from dual connect by level<=(select months_between(to_date('"+sendMonthT+"01','yyyyMMdd'),to_date('"+sendMonthF+"01','yyyyMMdd')) from dual)+1)";
		dbs.setSql(sql);
		List listM=dbs.queryForList();
		for(int i=0;i<listM.size();i++){
		  VariantSet vs1=(VariantSet)listM.get(i);
		  xMonth+="'"+vs1.getString(0).substring(2,6)+"',";
		  
		  costY+= vs1.getString("costv")+",";
		  incomeY+=vs1.getString("incomev")+",";
		}
		xMonth=xMonth.substring(0,xMonth.length()-1); 
			 	 
		 
		 series+="{name:'人力成本',data:["+costY.substring(0,costY.length()-1)+"]},";

		series+="{name:'收入',data:["+(incomeY.equals("")?"":incomeY.substring(0,incomeY.length()-1))+"]},";
	
		dbs.close();
			 
		series=series.substring(0,series.length()-1); 
			  
		%>
		
		var chart;
			$(document).ready(function() {
				chart = new Highcharts.Chart({
					chart: {
						renderTo: 'container',
						defaultSeriesType: 'column'
					},
					title: {
						text: ''
					},
					subtitle: {
						text: ''
					},
					xAxis: {
						categories: [<%=xMonth%>]
					},
					yAxis: {
						title: {
							text: '金额(RMB)'
						}
					},
					tooltip: {
					    crosshairs: true,
						shared: true
					
					},
					plotOptions: {
						line: {
							dataLabels: {
								enabled: true
							},
							enableMouseTracking: false
						},
						spline: {
							marker: {
								radius: 4,
								lineColor: '#666666',
								lineWidth: 1
							}
						}
					},
					series: [<%=series%>]
				});
				
				
			});
				
		</script>

  </head>
  
  <body>
    <div id="container" style="width: 100%; height: 100%; margin: 0 auto"></div>

  </body>
</html>
